emscriptenを動かしてみる
概要
簡単な纏めまでに。
あんまり人の環境とか汚したくないので、全部「どこかのフォルダ」に纏めていれるよう、
cd emsTest とかやってから実行してるものとします。
LLVM
curl -O http://llvm.org/releases/3.0/clang+llvm-3.0-x86_64-apple-darwin11.tar.gz
tar -xvzf clang+llvm-3.0-x86_64-apple-darwin11.tar.gz
rm clang+llvm-3.0-x86_64-apple-darwin11.tar.gz
node
必要。要らなく出来ないかなあ、、
emscripten自体をinstall
git clone git://github.com/kripken/emscripten.git
コンパイルする対象を用意
手始めに、helloworld.cを用意。
#include <stdio.h>
int main()
{
puts("Hello World");
}
実行
cd emscripten
./emcc ../hello.c
で、適当にソースコードを宛ててみるも、
FATAL: Cannot find /Users/tinoue/Dev/llvm-3.0/cbuild/bin/clang++, check the paths in ~/.emscripten
っていわれる。確かにそんなフォルダはない。
デフォルトで併せてあげてもよかったんだけど、めんどいので設定ファイルを弄る。
件の bin/clang++ 自体は、
emsTest/clang+llvm-3.0-x86_64-apple-darwin11/bin
に展開されてるので、
emscripten側のpathを書き換えるだけ。
自分だと、次の2行を弄った。
EMSCRIPTEN_ROOT = os.path.expanduser('~/emsTest/emscripten') # this helps projects using emscripten find it
と
LLVM_ROOT = os.path.expanduser('~/emsTest/clang+llvm-3.0-x86_64-apple-darwin11/bin')
→
./emcc ../hello.c
とかやると、
emscriptenフォルダ内にa.out.js吐けた。